home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / cuj1008.zip / 1008014A < prev    next >
Text File  |  1992-06-12  |  489b  |  29 lines

  1.  
  2. Listing 3 -- exit.c
  3.  
  4. /* exit function */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "yfuns.h"
  8.  
  9.         /* macros */
  10. #define NATS    32
  11.         /* static data */
  12. void (*_Atfuns[NATS])(void) = {0};
  13. size_t _Atcount = {NATS};
  14.  
  15. void (exit)(int status)
  16.     {    /* tidy up and exit to system */
  17.     while (_Atcount < NATS)
  18.         (*_Atfuns[_Atcount++])();
  19.      {    /* close all files */
  20.     size_t i;
  21.  
  22.     for (i = 0; i < FOPEN_MAX; ++i)
  23.         if (_Files[i])
  24.             fclose(_Files[i]);
  25.      }
  26.     _Exit(status);
  27.     }
  28.  
  29.